import type { Method } from "axios";

export interface ApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
}

export interface Api<T> {
  url: string;
  method: Method;
  map: T;
  params?: {
    [p: string]: "string" | "number";
  }[];
}

export const genApi = <T>(api: Api<T>): Api<T> => {
  return {
    url: api.url,
    method: api.method,
    map: api.map,
    params: api.params,
  };
};
